<template>
   <div style="width:420px;height:250px" ref="chart"></div>
</template>

<script>
import axios from 'axios'
import * as echarts from 'echarts'
export default {
    data(){
        return{
            xAxis:[],
            series:[]
        }
    },
    methods:{
        async getUserData(){
            const result=await axios.get('https://v4.crmeb.net/adminapi/home/user',{
                headers:{
                    'Authori-Zation':'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwd2QiOiJhZDIxOGMxNzE3MmI2NzdmNDY5N2UxZjU2YWY3YzlmZSIsImlzcyI6InY0LmNybWViLm5ldCIsImF1ZCI6InY0LmNybWViLm5ldCIsImlhdCI6MTcwODU4ODY3MywibmJmIjoxNzA4NTg4NjczLCJleHAiOjE3MTExODA2NzMsImp0aSI6eyJpZCI6NSwidHlwZSI6ImFkbWluIn19.mRkReyh-wApUymo7EbcGcTU3oilxnRYq66HjHDIbtPU'
                }
            })
            this.xAxis=result.data.data.xAxis
            this.series=result.data.data.series
        }
    },
    created(){
        this.getUserData()
    },
    computed:{
        options(){
            return{
                xAxis:{
                    data:this.xAxis
                },
                yAxis:{},
                series:[
                    {
                        type:'line',
                        data:this.series
                    }
                ]
            }
        }
    },
    watch:{
       series:{
        handler(){
           this.chart.setOption(this.options)
        }
       } 
    },
    mounted(){
        this.chart=echarts.init(this.$refs.chart)
       
    }
}
</script>

<style>

</style>